home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / pdcsrc.lzh / A68k / A68k.doc < prev    next >
Text File  |  1990-04-19  |  29KB  |  688 lines

  1.     A68k - a freely distributable assembler for the Amiga
  2.  
  3.             by Charlie Gibbs
  4.  
  5.              with special thanks to
  6.         Brian R. Anderson and Jeff Lydiatt
  7.  
  8.                  (Version 2.6 - November 2, 1989)
  9.  
  10.      Note:  This program is Freely Distributable, as opposed to Public
  11. Domain.  Permission is given to freely distribute this program provided no
  12. fee is charged, and this documentation file is included with the program.
  13.  
  14.      This assembler is based on Brian R. Anderson's 68000 cross-
  15. assembler published in Dr. Dobb's Journal, April through June 1986.
  16. I have converted it to produce AmigaDOS-format object modules, and
  17. have made many enhancements, such as macros and INCLUDE files.
  18.  
  19.      My first step was to convert the original Modula-2 code into C.
  20. I did this for two reasons.  First, I had access to a C compiler, but
  21. not a Modula-2 compiler.  Second, I like C better anyway.
  22.  
  23.      The executable code generator code (GetObjectCode and MergeModes)
  24. is essentially the same as in the original article, aside from its
  25. translation into C.  I have almost completely rewritten the remainder
  26. of the code, however, in order to remove restrictions, add enhancements,
  27. and adapt it to the AmigaDOS environment.  Since the only reference book
  28. available to me was the AmigaDOS Developer's Manual (Bantam, February
  29. 1986), the assembler and the remainder of this document work in terms
  30. of that book.
  31.  
  32.  
  33. RESTRICTIONS
  34.  
  35.      Let's get these out of the way first:
  36.  
  37.       o The verification file (-v) option is not supported.  Diagnostic
  38.     messages always appear on the console.  They also appear in the
  39.     listing file, however (see extensions below).  You can produce
  40.     an error file by redirecting console output to a file - the
  41.     line number counter and final summary are displayed on stderr
  42.     so you can still see what's happening.
  43.  
  44.       o The file names in the INCLUDE directory list (-i) must be
  45.     separated by commas.  The list may not be enclosed in quotes.
  46.  
  47.       o Labels assigned by EQUR and REG directives are case-sensitive.
  48.  
  49.       o Strange things will happen if your source code (including
  50.     INCLUDE files and macro expansions) exceeds 32,766 lines.
  51.     Tough darts.  Break up your source file.  Can you actually
  52.     read that monster?  :-)
  53.  
  54.       o The following directives are not supported, and will be flagged
  55.     as invalid op-codes:
  56.  
  57.         OFFSET
  58.         NOPAGE
  59.         LLEN
  60.         PLEN
  61.         NOOBJ
  62.         FAIL
  63.         FORMAT
  64.         NOFORMAT
  65.         MASK2
  66.  
  67.     I feel that NOPAGE, LLEN, and PLEN should not be defined within
  68.     a source module.  It doesn't make sense to me to have to change
  69.     your program just because you want to print your listings on
  70.     different paper.  The command-line switch "-p" (see below) can
  71.     be used as a replacement for PLEN; setting it to a high value
  72.     (like 32767) is a good substitute for NOPAGE.  The effect of
  73.     LLEN can be obtained by running the listing file through an
  74.     appropriate filter.
  75.  
  76.  
  77. EXTENSIONS
  78.  
  79.      Now for the good stuff:
  80.  
  81.       o Labels can be any length that will fit onto one source line
  82.     (currently 127 bytes maximum).  Since labels are stored on the
  83.     heap, the number of labels that can be processed is limited
  84.     only by available memory.
  85.  
  86.       o Since section data and user macro definitions are stored in
  87.     the symbol table (see above), they too are limited only by
  88.     available memory.  (Actually, there is a hard-coded limit of
  89.     32,767 sections, but I doubt anyone will run into that one.)
  90.  
  91.       o The only values a label cannot take are the register names -
  92.     A68k can distinguish between the same name used as a label,
  93.     instruction name or directive, macro name, or section name.
  94.  
  95.       o Section and user macro names appear in the symbol table dump,
  96.     and will also be cross-referenced.  Their names can be the same
  97.     as any label (see above); they will be listed separately.
  98.  
  99.       o INCLUDEs and macro calls can be nested indefinitely, limited
  100.     only by available memory.  The message "Secondary heap
  101.     overflow - assembly terminated" will be displayed if memory
  102.     is exhausted.  You can increase the size of this heap using
  103.     the -w switch (see below).  Recursive macros are supported;
  104.     recursive INCLUDEs will, of course, result in a loop that
  105.     will be broken only when the heap overflows.
  106.  
  107.       o The EVEN directive forces alignment on a word (2-byte)
  108.     boundary.  It does the same thing as CNOP 0,2.
  109.     (This one is left over from the original code.)
  110.  
  111.       o Backward references to labels within the current CODE section
  112.     will be converted to PC-relative addressing with displacement
  113.     if this mode is legal for the instruction.  This feature is
  114.     disabled by the -n switch.
  115.  
  116.       o If a MOVEM instruction only specifies one register, it is
  117.     converted to the corresponding MOVE instruction.  Instructions
  118.     such as MOVEM D0-D0,label will not be converted, however.
  119.     This feature is disabled by the -n switch.
  120.  
  121.       o ADD, SUB, and MOVE instructions will be converted to ADDQ,
  122.     SUBQ, and MOVEQ respectively if possible.  Instructions coded
  123.     explicitly (e.g. ADDA or ADDI) will not be converted.  This
  124.     feature is disabled by the -n switch.
  125.  
  126.       o ADD, CMP, SUB, and MOVE to an address register are converted to
  127.     ADDA, CMPA, SUBA, and MOVEA respectively, unless (for ADD, SUB,
  128.     or MOVE) they have already been converted to quick form.
  129.  
  130.       o ADD, AND, CMP, EOR, OR, and SUB of an immediate value are
  131.     converted to ADDI, ANDI, CMPI, EORI, ORI, and SUBI respectively
  132.     (unless the address register or quick conversion above has
  133.     already been done).
  134.  
  135.       o If both operands of a CMP instruction are postincrement mode,
  136.     the instruction is converted to CMPM.
  137.  
  138.       o Operands of the form 0(An) will be treated as (An) except for
  139.     the MOVEP instruction, which always requires a displacement.
  140.     This feature is disabled by the -n switch.
  141.  
  142.       o The SECTION directive allows a third parameter.  This can be
  143.     specified as either CHIP or FAST (upper or lower case).  If
  144.     this parameter is present, the hunk will be written with the
  145.     MEMF_CHIP or MEMF_FAST bit set.  This allows you to produce
  146.     "pre-ATOMized" object modules.
  147.  
  148.       o The synonyms DATA and BSS are accepted for SECTION directives
  149.     starting data or BSS hunks.  The CHIP and FAST options (see
  150.     above) can also be used, e.g. BSS name,CHIP.
  151.  
  152.       o The following synonyms have been implemented for compatibility
  153.     with the Aztec assembler:
  154.         CSEG is treated the same as CODE or SECTION name,CODE
  155.         DSEG is treated the same as DATA or SECTION name,DATA
  156.         PUBLIC is treated as either XDEF or XREF, depending on
  157.             whether or not the symbol in question has been
  158.             defined in the current source module.
  159.             A single PUBLIC directive can name a mixture
  160.             internally- and externally-defined symbols.
  161.  
  162.       o The ability to produce Motorola S-records is retained from the
  163.     original code.  The -s switch causes the assembler to produce
  164.     S-format instead of AmigaDOS format.  Relocatable code cannot
  165.     be produced in this format.
  166.  
  167.       o Error messages consist of three parts.
  168.         The position of the offending line is given as a line
  169.     number within the current module.  If the line is within a
  170.     macro expansion or INCLUDE file, the position of the macro
  171.     call or INCLUDE statement in the outer module is given as
  172.     well.  This process is repeated until the outermost source
  173.     module is reached.
  174.         Next, the offending source line itself is listed.
  175.         Finally, the errors for that line are displayed.  A flag
  176.     (^) is placed under the column where the error was detected.
  177.  
  178.       o Named local labels are supported.  These work the same as the
  179.     local labels supported by the Metacomco assembler (nnn$) but
  180.     are formed in the same manner as normal labels, except that
  181.     they must be preceded by a backslash (\).
  182.  
  183.       o The following synonyms have been implemented for compatibility
  184.     with the Assempro assembler:
  185.         ENDIF is treated the same as ENDC
  186.         = is treated the same as EQU
  187.         | is treated the same as ! (logical OR)
  188.  
  189.       o Quotation marks (") can be used as string delimiters
  190.     as well as apostrophes (').  Any given string must begin
  191.     and end with the same delimiter.  This allows such statements
  192.     as the following:
  193.         MOVEQ    "'",D0
  194.         DC.B    "This is Charlie's assembler."
  195.     Note that you can still define an apostrophe within a string
  196.     delimited by apostrophes if you double it, e.g.
  197.         MOVEQ    '''',D0
  198.         DC.B    'This is Charlie''s assembler.'
  199.  
  200.       o If any errors are found in the assembly, the object code file
  201.     will be scratched, unless you specified the -k (keep) flag
  202.     on the command line.
  203.  
  204.       o The symbols .A68K, .a68k, .a68K, and .A68k are automatically
  205.     defined as SET symbols having absolute values of 1.
  206.     This enables a source program to determine whether it is
  207.     being assembled by this assembler, and is effectively
  208.     insensitive as to whether or not it is checked in upper case.
  209.  
  210.       o A zeroth positional macro parameter (\0) is supported.  It
  211.     is replaced by the length of the macro call (B, W, or L,
  212.     defaulting to W).  For instance, given the macro:
  213.  
  214.         moov    MACRO
  215.             move.\0    \1,\2
  216.             ENDM
  217.  
  218.     the macro call
  219.  
  220.             moov.l    d0,d1
  221.  
  222.     would be expanded as
  223.  
  224.             move.l    d0,d1
  225.  
  226.       o If an INCLUDE file doesn't generate any code and no listing
  227.     file is required (including suppression of the listing using
  228.     NOLIST), it won't be read again in pass 2.  The statement
  229.     numbers will be bumped to keep in proper alignment.  This
  230.     can really speed up assemblies that INCLUDE lots of EQUates.
  231.  
  232.       o The ORG directive is supported.  It works like RORG, except
  233.     that it takes the actual address to be jumped to, rather
  234.     than an offset from the start of the current section.
  235.     The given address must be in the current section.
  236.     As far as A68k is concerned, the only real difference
  237.     between ORG and RORG is that the ORG value must be
  238.     relocatable, while the RORG value must be absolute.
  239.  
  240.       o Branch (Bcc, including BRA and BSR) instructions will be
  241.     converted to short form if possible.  Shortening a branch
  242.     may bring other branches within range of shortening - this
  243.     can set up a ripple effect, and A68k may not catch all
  244.     branches that could theoretically be optimized.  Any branches
  245.     which A68k misses (there shouldn't be too many under normal
  246.     circumstances) can be displayed by specifying the -f switch
  247.     (see below).  Branch optimization is disabled by the -n switch.
  248.  
  249.  
  250. THE SMALL CODE / SMALL DATA MODEL
  251.  
  252.      Version 2.4 implements a rudimentary small code/data model.
  253. It consists of converting any data reference to one of the following
  254. three addressing modes:
  255.  
  256.     address register indirect with displacement using a
  257.         specified address register, defaulting to A4
  258.         (for references to the DATA or BSS section)
  259.     program counter indirect with displacement
  260.         (for references to the CODE section)
  261.     absolute word
  262.         (for absolute and 16-bit relocatable values)
  263.  
  264. These conversions do not take place unless a NEAR directive is
  265. encountered.  The NEAR directive can take one operand, which
  266. must be either an address register or a symbol which has been
  267. equated (using EQUR) to an address register.  Register A7 (SP)
  268. may not be used.  If no register is given, A4 is assumed.
  269.  
  270.      Conversion is done for all operands until a FAR directive
  271. is encountered.  NEAR and FAR directives can occur any number
  272. of times, enabling conversion to be turned on and off at will.
  273.  
  274.      Backward references which cannot be converted (e.g. external
  275. labels declared as XREF) will remain as absolute long addressing.
  276. All forward references are assumed to be convertible, since during
  277. pass 1 A68k has no way of telling whether conversion is possible.
  278. If conversion turns out to be impossible, invalid object code will
  279. be generated - an error message ("Invalid forward reference") will
  280. indicate when this occurs.
  281.  
  282.      Although the small code/data model can greatly reduce the
  283. size of assembled programs, several restrictions apply:
  284.  
  285.       o Small code and small data models are active simultaneously.
  286.     You can't have one without the other, since during pass 1
  287.     A68k doesn't know whether forward references are to CODE
  288.     or to DATA/BSS.
  289.  
  290.       o Programs can consist of a maximum of two sections,
  291.     one CODE, the other DATA or BSS.  If you try to define
  292.     a third section, the message "Too many SECTIONs" will
  293.     be displayed.  The NEAR directive is active only within
  294.     the CODE section.
  295.  
  296.       o While the NEAR directive is active, external labels (XREF)
  297.     must be declared before they are used, CODE section references
  298.     must be with 32K of the current position (i.e. expressible as
  299.     PC-relative), and DATA/BSS section references must be in the
  300.     first 64K of the DATA/BSS section (i.e. expressible as
  301.     address register indirect with displacement).  Any instructions
  302.     which do not satisfy these requirements cannot be detected in
  303.     pass 1, so A68k has no choice but to display an error message
  304.     in pass 2 ("Invalid forward reference") which in this case
  305.     indicates that invalid code has been generated.  To properly
  306.     assemble such instructions, you can temporarily disable
  307.     conversion with a FAR directive, then resume afterwards
  308.     with another NEAR directive.
  309.  
  310.       o Conversion cannot be done for references between modules.
  311.     All external references must be left as absolute long.
  312.  
  313.       o A68k assumes that the base register (normally A4) points to
  314.     the start of the DATA/BSS section plus 32768 bytes.  The
  315.     register must be preloaded with this value before executing
  316.     any code converted by the NEAR directive.  One way to do this
  317.     is to code the instruction that loads the register prior to
  318.     the NEAR directive.  Another way is to use a MOVE.L with
  319.     immediate mode, which is never     converted.  Here are examples
  320.     of the two methods:
  321.  
  322.         LEA    data+32768,a4        NEAR
  323.         NEAR    ;defaults to A4        MOVE.L    #data+32768,a4
  324.         <remainder of code>            <remainder of code>
  325.         BSS                BSS
  326.     data:                data:
  327.         <data areas>            <data areas>
  328.         END                END
  329.  
  330.      I'll be the first to admit that this is a very crude and ugly
  331. implementation.  I hope to improve it in future versions.
  332.  
  333.  
  334. FILES
  335.  
  336.      A68k uses the following files:
  337.  
  338.       o The source code file - this file contains the program to be
  339.     assembled.  This file is an ASCII text file whose last line
  340.     must be an END statement.
  341.  
  342.       o The object code file - this file is created by A68k, replacing
  343.     any previous version which may exist.  If any errors are
  344.     encountered during the assembly, this file will be scratched,
  345.     unless the -k (keep) switch is specified (see below).
  346.     Although this file is normally written in AmigaDOS format,
  347.     the -s switch (see below) will cause it to be written in
  348.     Motorola S-record format instead.
  349.  
  350.       o The listing file - this file is optionally created by A68k
  351.     and contains a listing complete with page headings (including
  352.     form feeds), generated object code, and error messages if any.
  353.     It is suitable for feeding to a printer.
  354.  
  355.       o An equate file - this file is optionally created by A68k
  356.     and consists of a leading comment line followed by EQU
  357.     statements, one for each symbol encountered by A68k whose
  358.     value is absolute.  This file is only created if the -e
  359.     command-line switch is specified (see below).
  360.  
  361.       o A header file - if requested, this file is read by A68k
  362.     immediately prior to the source code file.  It treated
  363.     exactly as if it were requested by an INCLUDE statement
  364.     at the front of the source file, but is selected only if
  365.     the -h command-line switch is specified (see below).
  366.  
  367.       o Include files are selected by INCLUDE directives within the
  368.     source file, and are inserted in the source code in place
  369.     of the INCLUDE directive itself.  A68k first searches the
  370.     current directory for INCLUDE files; the -i command-line
  371.     switch (see below) specifies additional directories which
  372.     can be searched.
  373.  
  374.  
  375. FILE NAMES
  376.  
  377.      The names of the above files can be explicitly specified.
  378. However, A68k will generate default file names in the following cases:
  379.  
  380.       o If the -o switch is omitted, a default name will be assigned
  381.     to the object code file.
  382.  
  383.       o If the -e switch is specified with no file name, a default
  384.     name will be assigned to the equate file.
  385.  
  386.       o If the -l or -x switch is specified with no file name, a
  387.     default name will be assigned to the listing file.
  388.  
  389. A default name is generated by deriving a stem name from the source
  390. code file name, and appending .o for an object code file name (.s
  391. if the -s switch is specified to produce Motorola S-records), .equ
  392. for an equate file name, or .lst for a listing file name.  The stem
  393. name consists of all characters of the source file name up to the
  394. last period (or the entire source file name if it contains no period).
  395. Here are some examples:
  396.                            Default names
  397.             --------------------------------------------
  398.     Source file    Object file    Equate file    Listing file
  399.     -----------    -----------    -----------    ------------
  400.     myprog.asm    myprog.o    myprog.equ    myprog.lst
  401.     myprog        myprog.o    myprog.equ    myprog.lst
  402.     new.prog.asm    new.prog.o    new.prog.equ    new.prog.lst
  403.  
  404.  
  405. HOW TO USE A68k
  406.  
  407.      The command-line syntax to run the assembler is as follows:
  408.  
  409.     a68k <source file name>
  410.          [<object file name>]
  411.          [<listing file name>]
  412.         [-d[[!]<prefix>]]
  413.         [-e[<equate file name>]]
  414.         [-f]
  415.         [-h<header file name>]
  416.         [-i<INCLUDE directory list>]
  417.         [-k]
  418.         [-l[<listing file name>]]
  419.         [-n]
  420.         [-o<object file name>]
  421.         [-p<page depth>]
  422.         [-q[<quiet interval>]]
  423.         [-s]
  424.         [-t]
  425.         [-w[<hash table size>][,<secondary heap size>]]
  426.         [-x[<listing file name>]]
  427.         [-y]
  428.         [-z[<debug start line>][,<debug end line>]]
  429.  
  430. These options can be given in any order.  Any parameter which is not
  431. a switch (denoted by a leading hyphen) is assumed to be a file name;
  432. up to three file names (assumed to be source, object, and listing file
  433. names respectively) can be given.  A source file name is always required.
  434. If a switch is being given a value, that value must immediately follow
  435. the switch letter with no intervening spaces.  For instance, to specify
  436. a page depth of 40 lines, the specification "-p40" should be used;
  437. "-p 40" will be rejected.
  438.  
  439. Switches perform the following actions:
  440.  
  441.      -d causes symbol table entries (hunk_symbol) to be written
  442.     to the object module for the use of symbolic debuggers.
  443.     If the switch is followed by a string of characters, only
  444.     those symbols beginning with that prefix string will be
  445.     written.  This can be used to suppress internal symbols
  446.     generated by compilers.  If the first character is an
  447.     exclamation mark (!), only symbols which do NOT begin
  448.     with the following characters are written out.
  449.  
  450.     Here are some examples:
  451.  
  452.         -d    writes all symbols
  453.         -dabc    writes only symbols beginning with "abc"
  454.         -d!x    writes symbols which do not begin with "x"
  455.  
  456.      -e causes an equate file (see above) to be produced.  A file
  457.     name can be specified; otherwise a default name will be used.
  458.  
  459.      -f causes any branches (Bcc, BRA, BSR) that could be converted
  460.     to short form to be flagged.  A68k will convert as many
  461.     branches as possible to short form (unless the -n switch is
  462.     is specified), but certain combinations of instructions may
  463.     set up a ripple effect where shortening one branch brings
  464.     another one into range.  This switch will cause A68k to
  465.     flag any branches that it may have missed; during pass 2
  466.     it is possible to tell this, although during pass 1 it might
  467.     not be.  If the -n switch (see below) is specified along
  468.     with this switch (suppressing all optimization), no branches
  469.     will be shortened, but all branches which could be shortened
  470.     will be flagged.
  471.  
  472.      -h causes a header file to be read prior to the source code file.
  473.     A file name must be given.  The action is the same as if the
  474.     first statement of the source file were an INCLUDE statement
  475.     naming the header file.  To find the header file, the same
  476.     directories will be searched as for INCLUDE files (see the
  477.     -i switch below).
  478.  
  479.      -i specifies directories to be searched for INCLUDE files in
  480.     addition to the current directory.  Several names, separated
  481.     by commas, may be specified.  No embedded blanks are allowed.
  482.     For example, the specification
  483.  
  484.         -imylib,df1:another.lib
  485.  
  486.     will cause INCLUDE files to be searched for first in the
  487.     current directory, then in "mylib", then in "df1:another.lib".
  488.  
  489.      -k causes the object file to be kept even if any errors were
  490.     found.  Otherwise, it will be scratched if any errors occur.
  491.  
  492.      -l causes a listing file to be produced.  If you want the listing
  493.     file to include a symbol table dump and cross-reference, use
  494.     the -x switch instead (see below).
  495.  
  496.      -n causes all object code optimization (see above) to be disabled.
  497.  
  498.      -o allows the default name for the object code file (see above)
  499.     to be overridden.
  500.  
  501.      -p causes the page depth to be set to the specified value.
  502.     This takes the place of the PLEN directive in the Metacomco
  503.     assembler.  Page depth defaults to 60 lines (-p60).
  504.  
  505.      -q changes the interval at which A68k displays the line number
  506.     it has reached in its progress through the assembly.  The
  507.     default is to display every 10 lines (-q10).  Specifying
  508.     larger values reduces console I/O, making assemblies run
  509.     slightly faster.
  510.  
  511.     If you specify a negative number (e.g.     -q-10), line numbers
  512.     will be displayed at an interval equal to the absolute value
  513.     of the specified number, but will be given as positions
  514.     within the current module (source, macro, or INCLUDE) rather
  515.     than as a total statement count - the module name will also
  516.     be displayed.
  517.  
  518.     A special case is the value zero (-q0 or just -q) - this
  519.     will cause all console output, except for error messages,
  520.     to be suppressed.
  521.  
  522.      -s causes the object file to be written in Motorola S-record
  523.     format, rather than AmigaDOS format.  The default name for
  524.     an S-record file ends with ".s" rather than ".o"; this can
  525.     still be overridden with the -o switch, though.
  526.  
  527.      -t allows tabs in the source file to be passed through to the
  528.     listing file, rather than being expanded.  In addition, tabs
  529.     will be generated in the listing file to skip from the object
  530.     code to the source statement, etc.  This can greatly reduce
  531.     the size of the listing file, as well as making it quicker to
  532.     produce.  Do not use this option if you will be displaying or
  533.     listing the list file on a device which does not assume a tab
  534.     stop at every 8th position.
  535.  
  536.      -w specifies the sizes of fixed memory areas that A68k allocates
  537.     for its own use.  You should normally never have to specify
  538.     this switch, but it may be useful for tuning.
  539.  
  540.     The first parameter gives the number of entries that the hash
  541.     table (used for searching the symbol table) will contain.
  542.     The default value of 2047 should be enough for all but the
  543.     very largest programs.  The assembly will not fail if this
  544.     value is too small, but may slow down if too many long hash
  545.     chains must be searched.  The hashing statistics displayed by
  546.     the -y switch (see below) can be used to tune this parameter.
  547.     I've heard that you should really specify a prime number for
  548.     this parameter, but I haven't gone into hashing theory enough
  549.     to know whether it's actually necessary.
  550.  
  551.     The second parameter of the -w switch specifies the size (in
  552.     bytes) of the secondary heap, which is used to store nested
  553.     macro and INCLUDE file information (see below).  It defaults
  554.     to 1024, which should be enough unless you use very deeply
  555.     nested macros and/or INCLUDE files with long path names.
  556.  
  557.     You can specify either or both parameters.  For example:
  558.  
  559.         -w4093       secondary heap size remains at 1024 bytes
  560.         -w,2000      hash table size remains at 2047 entries
  561.         -w4093,2000  increases the size of both areas
  562.  
  563.     If you're really tight for memory, and are assembling small
  564.     modules, you can use this switch to shrink these areas below
  565.     their default sizes.  At the end of an assembly, a message
  566.     will be displayed giving the sizes actually used, in the form
  567.     of the -w command you would have to enter to allocate that much
  568.     space.  This is primarily useful to see how much secondary
  569.     heap space was used.
  570.  
  571.     NOTE: All other memory used by A68k (e.g. the actual symbol
  572.     table) is allocated as required (currently in 8K chunks).
  573.  
  574.      -x works the same as -l (see above), except that a symbol table
  575.     dump, including cross-reference information, will be added
  576.     to the end of the listing file.
  577.  
  578.      -y causes hashing statistics to be displayed at the end of the
  579.     assembly.  First the number of symbols in the table is given,
  580.     followed by a summary of hash chains by length.  Chains with
  581.     length zero denote unused hash table entries.  Ideally (i.e.
  582.     if there were no collisions) there should be as many chains
  583.     with length 1 as there are symbols, and there should be no
  584.     chains of length 2 or greater.  I added this option to help
  585.     me tune my hashing algorithm, but you can also use it to see
  586.     whether you should allocate a larger hash table (using the
  587.     first parameter of the -w switch, see above).
  588.  
  589.      -z was provided to help debug A68k itself.  It causes A68k to
  590.     list a range of source lines, complete with line number and
  591.     current location counter value, during both passes.  Lines
  592.     are listed immediately after they have been read from the
  593.     source file, before any processing occurs.
  594.  
  595.     Here are some examples of the -z switch:
  596.  
  597.         -z        lists all source lines
  598.         -z100,200    lists lines 100 through 200
  599.         -z100        lists all lines starting at 100
  600.         -z,100        lists the first 100 lines
  601.  
  602.  
  603. TECHNICAL INFORMATION
  604.  
  605.      The actual symbol table entries (pointed to by the hash table,
  606. colliding entries are linked together) are stored in 8K chunks which
  607. are allocated as required.  The first entry of each chunk is reserved
  608. as a link to the next chunk (or NULL in the last chunk) - this makes
  609. it easy to find all the chunks to free them when we're finished.  All
  610. symbol table entries are stored in pass 1.  During pass 2, cross-
  611. reference table entries are built in the same group of chunks,
  612. immediately following the last symbol table entry.  Additional chunks
  613. will continue to be linked in if necessary.
  614.  
  615.      Symbol names and macro text are stored in another series of linked
  616. chunks.  These chunks consist of a link pointer followed by strings
  617. (terminated by nulls) laid end to end.  Symbols are independent entries,
  618. linked from the corresponding symbol table entry.  Macros are stored as
  619. consecutive strings, one per line - the end of the macro is indicated by
  620. an ENDM statement.  If a macro spans two chunks, the last line in the
  621. original chunk is followed by a newline character to indicate that the
  622. macro is continued in the next chunk.
  623.  
  624.      Relocation information is built during pass 2 in yet another
  625. series of linked chunks.  If more than one chunk is needed to hold one
  626. section's relocation information, all additional chunks are released
  627. at the end of the section.
  628.  
  629.      The secondary heap is built from both ends, and it grows and
  630. shrinks according to how many macros and INCLUDE files are currently
  631. open.  At all times there will be at least one entry on the heap, for
  632. the original source code file.  The expression parser also uses the
  633. secondary heap to store its working stacks - this space is freed as
  634. soon as an expression has been evaluated.
  635.      The bottom of the heap holds the names of the source code file
  636. and any macro or INCLUDE files that are currently open.  The full path
  637. is given.  A null string is stored for user macros.  Macro arguments
  638. are stored by additional strings, one for each argument in the macro
  639. call line.  All strings are stored in minimum space, similar to the
  640. labels and user macro text on the primary heap.  File names are
  641. pointed to by the fixed table entries (see below) - macro arguments
  642. are accessed by stepping past the macro name to the desired argument,
  643. unless NARG would be exceeded.
  644.      The fixed portion of the heap is built down from the top.  Each
  645. entry occupies 16 bytes.  Enough information is stored to return to
  646. the proper position in the outer file once the current macro or
  647. INCLUDE file has been completely processed.
  648.      The diagram below illustrates the layout of the secondary heap.
  649.  
  650.     Heap2 + maxheap2 ----------->  ___________________________
  651.                       |                  |
  652.                       |   Input file table      |
  653.     struct InFCtl *InF ---------> |___________________________|
  654.                       |                  |
  655.                       |   Parser operator stack      |
  656.     struct OpStack *Ops --------> |___________________________|
  657.                       |                  |
  658.                       |   (unused space)      |
  659.     struct TermStack *Term -----> |___________________________|
  660.                       |                  |
  661.                       |   Parser term stack      |
  662.     char *NextFNS --------------> |___________________________|
  663.                       |                  |
  664.                       |   Input file name stack      |
  665.     char *Heap2 ----------------> |___________________________|
  666.  
  667.      The "high-water mark" for NextFNS is stored in char *High2,
  668. and the "low-water mark" (to stretch a metaphor) for InF is stored
  669. in struct InFCtl *LowInF.  These figures are used only to determine
  670. the maximum heap usage.
  671.  
  672.  
  673. AND FINALLY...
  674.  
  675.      Please send me any bug reports, flames, etc.  I can be reached
  676. on Mind Link (604/533-2312), at any meeting of the Commodore
  677. Computer Club / Panorama (PAcific NORthwest AMiga Association),
  678. or via Jeff Lydiatt or Larry Phillips.  I don't have the time
  679. or money to live on Compuserve or BIX, but my Usenet address is
  680. Charlie_Gibbs@mindlink.UUCP (...uunet!van-bc!rsoft!mindlink!a218).
  681.  
  682.  
  683.                 Charlie Gibbs
  684.                 2121 Rindall Avenue
  685.                 Port Coquitlam, B.C.
  686.                 Canada
  687.                 V3C 1T9
  688.